import {Middleware} from "redux";
import throttle from "lodash/throttle"

export const throttleMiddleware = (actionTypes: string[]): Middleware => {
  return store => next => {
    const throttledNext = throttle(next, 1000);
    return action => {
      if (actionTypes.includes(action.type)) {
        throttledNext(action)
      } else {
        next(action);
      }
    }
  }
}
